<?php
class fadvertisings extends MY_Controller{
    var $menu_active = "advertisings";
    
    function __construct()
    {
        parent::__construct();
        $this->load->helper('remove_vn_helper');
    }

    function index($offset = 0, $limit = 10)
    {
        if(empty($offset))
            $offset = $this->uri->segment(2);

        //category news
        $cat_news = new Article();
        $cat_news->where(array('recycle'=>0));
        $cat_news->where('newscatalogue_id', 72);
        $cat_news->order_by('created','desc');
        $cat_news->get_paged($offset,$limit,TRUE);
        $dis['news'] = $cat_news;
        setPaginationVb('tin-tuc/', $cat_news->paged->total_rows, $limit, 2);

        //seo
        $category = new Newscatalogue(72);
        $this->page_title = $category->title_bar_vietnamese;
        $this->page_description = $category->slogan_vietnamese;
        $this->page_keyword = $category->keyword_vietnamese;
        
		$this->isRobotFollow = 1;
        $dis['base_url']=base_url();
        $this->uri = base_url().substr($this->uri->uri_string, 1, strlen($this->uri->uri_string));
        $dis['view']='front/advertisings/news';
        $this->viewfront($dis) ;
		
    }

	
	function detail($title_none = NULL){
        $title_none = gettitlenonefromlink($this->uri->segment(2));

        $news = new Article();
		$news->where(array('title_none'=>$title_none, 'newscatalogue_id'=>72));
        $news->get();
        if(!$news->exists())
            show_404();
        $dis['news'] = $news;

        $tag = $news->tag_vietnamese;
        $dis['tag'] = explode(',', $tag);

        $news->view_count = $news->view_count+1;
        $news->save();

        /*related news*/
        $related_news = new Article();
        $related_news->where('recycle',0);
        $related_news->where('newscatalogue_id',$news->newscatalogue_id);
        $related_news->where("id !=",$news->id);
        $related_news->order_by('created', 'DESC');
        $related_news->get_paged(0, 10, TRUE);
        $dis['related_news'] = $related_news;


        $this->page_title = $news->title_vietnamese;
        $this->page_description = $news->short_vietnamese;
        $this->page_keyword = $news->keyword_vietnamese;


		$this->isRobotFollow = 1;
        $this->uri = base_url().substr($this->uri->uri_string, 1, strlen($this->uri->uri_string));
        $dis['link'] = base_url().$_SERVER['REQUEST_URI'];
        $dis['base_url']=base_url();
        $dis['view']='front/advertisings/news_de';
        $this->viewfront($dis) ;
    }
}